const mongoose = require('mongoose');

const InviteCode = new mongoose.Schema({
   code: {
      type: String,
      required: true,
   },
   groupId: {
      type: mongoose.Types.ObjectId,
      ref: 'Group',
      required: true,
   },
});

const model = mongoose.model('InviteCode', InviteCode);
model.collection.createIndex(
   { expiresAt: 1 },
   { expireAfterSeconds: 60 * 60 * 24 }
);
module.exports = model;
